import { Controller, Post, Body } from '@nestjs/common';
import { ProjectService } from './projects.service';
import { IProject } from 'src/types/projects';

@Controller('project')
export class ProjectController {
  constructor(private readonly projectService: ProjectService) { }

  @Post('createZip')
  async createProjectZip(@Body() dirData: IProject): Promise<{ downloadUrl: string }> {
    const downloadUrl = await this.projectService.createProject(dirData, true);
    return { downloadUrl };
  }

  @Post('create')
  async createProject(@Body() dirData: IProject): Promise<{ projectPath: string }> {
    const projectPath = await this.projectService.createProject(dirData, false);
    return { projectPath };
  }

  @Post('update')
  async updateProject(@Body() dirData: IProject): Promise<{ projectPath: string }> {
    const projectPath = await this.projectService.updateProject(dirData);
    return { projectPath };
  }
}
